package com.kfm.servlet;

import com.kfm.model.Account;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/acocunt")
public class AccountServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 所有账户信息
        List<Account> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            Account account = new Account();
            account.setId(i + 10);
            account.setName("张三"+ i);
            account.setUsername("admin" + i);

            list.add(account);
        }

        req.setAttribute("accounts", list);

        req.getRequestDispatcher("account.jsp").forward(req, resp);
    }
}
